﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CMS.BLL;
using CMS.BLL.Entity;

public partial class Controls_Cruise_ctrCruiseDetails : System.Web.UI.UserControl
{
    private int nCurrentLang = Support.GetCurrentLanguage();
    private int nDefaultLang = Support.GetDefaultLanguage();
    private int nPageCount = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SetLangLable();
            LoadData();
        }
    }
    private int GetCountryID()
    {
        int nCountry = ConvertData.ConvertToInt(Request.QueryString["cid"]);
        if (nCountry == 0)
            nCountry = 1;

        return nCountry;
    }

    private void LoadData()
    {
        try
        {
            int nItemID = ConvertData.ConvertToInt(Request.QueryString[Config.CRUISEID]);
            lnkBook.NavigateUrl = "~/ContactUs.aspx";

            Cruise objCruise = new Cruise();
            DataTable dtbHetel = new DataTable();
            objCruise.LoadById(nItemID);
            ctrCruiseCatDetail_NoPaging1.setCruiseRegion(objCruise.Data.CountryID, objCruise.Data.CruiseRegion, objCruise.Data.Type, 3);


            string sCode = ConvertData.ConvertToString(objCruise.Data.VideoLink);
            sCode = sCode.Replace("215", "650").Replace("120", "450");
            ltrVideo.Text = sCode;

            if (objCruise.Data.Images != "")
                imgImage.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.Images.ToString();
            else imgImage.ImageUrl = Config.ROOT + "/Images/no_image.gif";

            Country objCountry = new Country();
            objCountry.LoadById(objCruise.Data.CountryID);
            lblCountry.Text = MultipleLanguage.LOCATION[nCurrentLang - 1];

            lblValPriceFrom.Text = "$" + ConvertData.ConvertToString(Support.FormatCurrency(objCruise.Data.PriceFrom)).Replace(".", "");
            lblValPriceFromTo.Text = "$" + ConvertData.ConvertToString(Support.FormatCurrency(objCruise.Data.PriceTo)).Replace(".", "");

            TourDuration objDuration = new TourDuration();
            objDuration.LoadById(objCruise.Data.CruiseDurationID);
            
            switch (nCurrentLang)
            {
                case 1:
                   
                    lblValCountry.Text = objCountry.Data.CountryName1;
                    lblTitle.Text = objCruise.Data.Title1;
                    ltrContent.Text = objCruise.Data.Content1;
                    lblInitContent.Text = ConvertData.TruncateString(objCruise.Data.InitContent1,300);
                    lblValDuration.Text = ConvertData.ConvertToString(objDuration.Data.DurationDescription1);
                    ltr2Days.Text = objCruise.Data.Content1_2day;
                    ltr3Days.Text = objCruise.Data.Content1_3day;
                    break;
                case 2:
                    
                    lblValCountry.Text = objCountry.Data.CountryName2;
                    lblTitle.Text = objCruise.Data.Title2;
                    ltrContent.Text = objCruise.Data.Content2;
                    lblInitContent.Text = ConvertData.TruncateString(objCruise.Data.InitContent2,300);
                    lblValDuration.Text = ConvertData.ConvertToString(objDuration.Data.DurationDescription2);
                    ltr2Days.Text = objCruise.Data.Content2_2day;
                    ltr3Days.Text = objCruise.Data.Content2_3day;
                    break;
                case 3:
                    
                    lblValCountry.Text = objCountry.Data.CountryName3;
                    lblTitle.Text = objCruise.Data.Title3;
                    
                    ltrContent.Text = objCruise.Data.Content3;
                    ltr2Days.Text = objCruise.Data.Content3_2day;
                    ltr3Days.Text = objCruise.Data.Content3_3day;
                    lblInitContent.Text =ConvertData.TruncateString(objCruise.Data.InitContent3,300);
                    lblValDuration.Text = ConvertData.ConvertToString(objDuration.Data.DurationDescription3);
                    break;
            }
            if (ConvertData.ConvertToString(objCruise.Data.ImageDetail1) != "")
            {
                Image1.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + ConvertData.ConvertToString(objCruise.Data.ImageDetail1);
            }
            else
            {
                Image1.Visible = false;
            }
            if (ConvertData.ConvertToString(objCruise.Data.ImageDetail2) != "")
            {
                Image2.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + ConvertData.ConvertToString(objCruise.Data.ImageDetail2);
            }
            else
            {
                Image2.Visible = false;
            }
            if (ConvertData.ConvertToString(objCruise.Data.ImageDetail3) != "")
            {
                Image3.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + ConvertData.ConvertToString(objCruise.Data.ImageDetail3);
            }
            else
            {
                Image3.Visible = false;
            }
            if (ConvertData.ConvertToString(objCruise.Data.ImageDetail4) != "")
            {
                Image4.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + ConvertData.ConvertToString(objCruise.Data.ImageDetail4);
            }
            else
            {
                Image4.Visible = false;
            }
            if (ConvertData.ConvertToString(objCruise.Data.ImageDetail5) != "")
            {
                Image5.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + ConvertData.ConvertToString(objCruise.Data.ImageDetail5);
            }
            else
            {
                Image5.Visible = false;
            }
        }
        catch
        {
            Response.Redirect("~/Default.aspx");
        }
    }
    private void SetLangLable()
    {
        lblOverview.Text = MultipleLanguage.LBL_TOUROVERVIEW[nCurrentLang - 1];
        lblImage.Text = MultipleLanguage.PICTURE_DETAIS[nCurrentLang - 1];
        lblVideo.Text = MultipleLanguage.VIDEO[nCurrentLang - 1];
        lblPriceFrom.Text = MultipleLanguage.CRUISEPRICE[nCurrentLang - 1];
        lblDuration.Text = MultipleLanguage.LBL_CRUISEDURATION[nCurrentLang - 1];
        lbl2Days.Text = MultipleLanguage.CRUISECONTENT2DAY[nCurrentLang - 1];
        lbl3Days.Text = MultipleLanguage.CRUISECONTENT3DAY[nCurrentLang - 1];
    }
}